<!DOCTYPE html>
<html lang="zh-hans">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{% block title %}考试系统{% endblock %}</title>
    <!-- Bootstrap CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- Common CSS -->
    {% load static %}
    <link rel="stylesheet" type="text/css" href="{% static 'css/common.css' %}">
    <!-- Custom CSS -->
    <style>
        body {
            padding-top: 60px;
        }
    </style>
    {% block extra_css %}{% endblock %}
</head>
<body>
    <!-- Navigation -->
    <nav class="navbar navbar-expand-lg navbar-dark bg-primary fixed-top">
        <div class="container">
            <a class="navbar-brand" href="{% url 'exam_system:index' %}">考试系统</a>
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarNav">
                <li class="nav-item">
                    <a class="nav-link" href="{% url 'exam_system:profile' %}">个人中心</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="{% url 'exam_system:notification_list' %}">
                        通知
                        <span class="badge badge-pill badge-primary" id="notification-count"></span>
                    </a>
                </li>
                    </li>
                    {% if request.session.examinee_id %}
                        <li class="nav-item">
                            <a class="nav-link" href="{% url 'exam_system:dashboard' %}">仪表盘</a>
                        </li>
                        {% if request.session.is_staff %}
                            <li class="nav-item">
                                <a class="nav-link" href="{% url 'exam_system:import_questions' %}">导入试题</a>
                            </li>
                            <li class="nav-item">
                                <a class="nav-link" href="{% url 'admin:index' %}">管理后台</a>
                            </li>
                        {% endif %}
                        <li class="nav-item">
                            <a class="nav-link" href="{% url 'exam_system:logout' %}">退出</a>
                        </li>
                    {% else %}
                        <li class="nav-item">
                            <a class="nav-link" href="{% url 'exam_system:login' %}">登录</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="{% url 'exam_system:register' %}">注册</a>
                        </li>
                    {% endif %}
                </ul>
            </div>
        </div>
    </nav>

    <!-- Main Content -->
    <div class="container mt-4">
        {% block content %}{% endblock %}
    </div>

    <!-- Footer -->
    <footer class="footer">
        <div class="container">
            <span class="text-muted">© 2025 深蓝考试系统 | 版权所有</span>
        </div>
    </footer>

    <!-- Bootstrap JS -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
    <!-- jQuery -->
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script>
        $(document).ready(function() {
            $('.refresh-captcha').click(function(e) {
                e.preventDefault();
                $.getJSON("/captcha/refresh/", function(result) {
                    // 更新验证码图片
                    $('.captcha').attr('src', result['image_url']);
                    // 更新验证码隐藏输入字段的值
                    $('#id_captcha_0').val(result['key']);
                });
            });
        });
    </script>
    {% block extra_js %}{% endblock %}
</body>
</html>